package com.iflytek.sbd.config;

import com.iflytek.sbd.filter.LoginFilter;
import com.iflytek.sbd.filter.ParameterFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: sbd
 * @description: 配置过滤器的测试操作,详情见配置文件
 * @author: 陈英俊
 * @create: 2021-12-30 14:59
 */
//@Configuration 关闭过滤器
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<LoginFilter> registerLoginFilter() {
        FilterRegistrationBean<LoginFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new LoginFilter());
        bean.setOrder(11);
        bean.addUrlPatterns("/demo/*");
        return bean;
    }


    @Bean
    public FilterRegistrationBean<ParameterFilter> registerParameterFilter() {
        FilterRegistrationBean<ParameterFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new ParameterFilter());
        bean.setOrder(2);
        bean.addUrlPatterns("/demo/*");
        return bean;
    }
}
